﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Read.API.Application.Command.DoctorCommand;
using D.Medicalcare.Read.API.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Read.API.Controllers
{
    /// <summary>
    /// 医生管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DoctorController : ControllerBase
    {

        private readonly IMediator mediator;

        public DoctorController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 医生管理显示带查询条件
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaging<DoctorDto>> GetDoctor([FromQuery]GetDoctorCommand request)
        {

            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 医生管理反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public  async Task<APIResult<Doctor>> FtDoctor([FromQuery]FtDoctorCommand request)
        {

            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }

        }


        }
}
